In [1]:
name = 'Sam'
In [2]:
name
Out[2]:
In [3]:
# name[0] = 'P'
last_letters = name[1:]
In [4]:
last_letters
Out[4]:
In [5]:
'P' + last_letters
Out[5]:
In [6]:
x = 'Hello World'
In [7]:
x + 'it is beautiful outside!'
Out[7]:
In [8]:
x = x + ' it is beautiful outside!'
In [9]:
x
Out[9]:
In [10]:
letter = 'z'
In [11]:
letter*10
Out[11]:
Difference in operators
In [12]:
2 + 3
Out[12]:
In [13]:
'2' + '3'
Out[13]:
In [14]:
2 * '2' + '3'
Out[14]:
In [15]:
2 * ('2' + '3')
Out[15]:
In [16]:
2 * ('2' + '$' + '3' + '£')
Out[16]:
In [17]:
2 * ('2' + '£' + '3' + '$') * 6
Out[17]:
In [18]:
2 * ('2' + '£' + '3' + '$') + 6
In [19]:
2 * ('2' + '£' + '3' + '$') * 6
Out[19]:
In [20]:
x = 'Hidie Hi'
In [21]:
x.capitalize()
Out[21]:
In [22]:
x.casefold()
Out[22]:
In [23]:
x.count(x)
Out[23]:
In [24]:
x = 'Hidie Hi'
In [25]:
x
Out[25]:
In [26]:
x.count(x)
Out[26]:
In [27]:
x.encode()
Out[27]:
In [28]:
x.endswith('die ho')
Out[28]:
In [29]:
x.endswith('i')
Out[29]:
In [30]:
x.find('e')
Out[30]:
In [31]:
x.index('i')
Out[31]:
In [32]:
x.isalpha()
Out[32]:
In [33]:
x.isdigit()
Out[33]:
In [34]:
x.upper()
Out[34]:
In [35]:
x
Out[35]:
In [36]:
x.swapcase()
Out[36]:
In [37]:
x.replace('i', 'a')
Out[37]:
In [38]:
x.split()
Out[38]:
In [39]:
x = 'Hi this is a string a ling a ding ding thing i write first in thin things.'
In [40]:
x.split('i')
Out[40]:
x.(press tab for string functions of x) this is only for notebook. Functions can be found elsewhere.
In [ ]: